package com.zhaoxi.project.mes.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhaoxi.framework.aspectj.lang.annotation.Log;
import com.zhaoxi.framework.aspectj.lang.enums.BusinessType;
import com.zhaoxi.project.mes.domain.MesBomRoute;
import com.zhaoxi.project.mes.service.impl.MesBomRouteServiceImpl;
import com.zhaoxi.framework.web.controller.BaseController;
import com.zhaoxi.framework.web.domain.AjaxResult;
import com.zhaoxi.common.utils.poi.ExcelUtil;
import com.zhaoxi.framework.web.page.TableDataInfo;

/**
 * 物品工艺路线清单Controller
 * 
 * @author zhaoxi
 * @date 2023-08-28
 */
@RestController
@RequestMapping("/mes/bomRoute")
public class MesBomRouteController extends BaseController
{
    @Autowired
    private MesBomRouteServiceImpl mesBomRouteService;

    /**
     * 查询物品工艺路线清单列表
     */
    @PreAuthorize("@ss.hasPermi('mes:bomRoute:list')")
    @GetMapping("/list")
    public TableDataInfo list(MesBomRoute mesBomRoute)
    {
        startPage();
        List<MesBomRoute> list = mesBomRouteService.selectMesBomRouteList(mesBomRoute);
        return getDataTable(list);
    }

    /**
     * 导出物品工艺路线清单列表
     */
    @PreAuthorize("@ss.hasPermi('mes:bomRoute:export')")
    @Log(title = "物品工艺路线清单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesBomRoute mesBomRoute)
    {
        List<MesBomRoute> list = mesBomRouteService.selectMesBomRouteList(mesBomRoute);
        ExcelUtil<MesBomRoute> util = new ExcelUtil<MesBomRoute>(MesBomRoute.class);
        util.exportExcel(response, list, "物品工艺路线清单数据");
    }

    /**
     * 获取物品工艺路线清单详细信息
     */
    @PreAuthorize("@ss.hasPermi('mes:bomRoute:query')")
    @GetMapping(value = "/{goodsCode}")
    public AjaxResult getInfo(@PathVariable("goodsCode") String goodsCode)
    {
        return success(mesBomRouteService.selectMesBomRouteByGoodsCode(goodsCode));
    }

    /**
     * 新增物品工艺路线清单
     */
    @PreAuthorize("@ss.hasPermi('mes:bomRoute:add')")
    @Log(title = "物品工艺路线清单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesBomRoute mesBomRoute)
    {
        return toAjax(mesBomRouteService.insertMesBomRoute(mesBomRoute));
    }

    /**
     * 修改物品工艺路线清单
     */
    @PreAuthorize("@ss.hasPermi('mes:bomRoute:edit')")
    @Log(title = "物品工艺路线清单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesBomRoute mesBomRoute)
    {
        return toAjax(mesBomRouteService.updateMesBomRoute(mesBomRoute));
    }

    /**
     * 删除物品工艺路线清单
     */
    @PreAuthorize("@ss.hasPermi('mes:bomRoute:remove')")
    @Log(title = "物品工艺路线清单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{goodsCodes}")
    public AjaxResult remove(@PathVariable String[] goodsCodes)
    {
        return toAjax(mesBomRouteService.deleteMesBomRouteByGoodsCodes(goodsCodes));
    }
}
